import axios from 'axios'
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
const service = axios.create({
  baseURL: import.meta.env.VITE_BASE_URL,
  timeout: 30000,
})
// request拦截器
service.interceptors.request.use(config => {
  // 是否需要设置 token
  config.headers['time'] = 'time'
  config.headers['sign'] = 'abc'
  return config
}, error => {
  Promise.reject(error)
})

// 响应拦截器
service.interceptors.response.use(res => {
  // console.log(res, 'res');
  let data = res.data
  return data
})

export default service
